<?php

use yii\db\Migration;

/**
 * Class m200804_060644_initialize
 */
class m200804_060644_initialize extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $CreateTableSQL = "
            
            CREATE TABLE `exercise_record` (
              `id` int(11) NOT NULL AUTO_INCREMENT,
              `questionId` int(11) DEFAULT NULL,
              `uid` int(11) DEFAULT NULL,
              `createTime` int(11) DEFAULT NULL,
              `option` int(11) DEFAULT NULL COMMENT '选项，为0表示正确',
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='练习记录';
            
            CREATE TABLE `favorite` (
              `id` int(11) NOT NULL AUTO_INCREMENT,
              `questionId` int(11) DEFAULT NULL,
              `uid` int(11) DEFAULT NULL,
              `createTime` int(11) DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='收藏';
            
            CREATE TABLE `leave_msg` (
              `id` int(11) NOT NULL AUTO_INCREMENT,
              `uid` int(11) DEFAULT NULL,
              `leaveMsg` varchar(500) DEFAULT NULL,
              `contactWay` varchar(200) DEFAULT NULL,
              `createTime` int(11) DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='留言';
            
            CREATE TABLE `mistake_record` (
              `id` int(11) NOT NULL AUTO_INCREMENT,
              `questionId` int(11) DEFAULT NULL,
              `option` int(11) DEFAULT NULL COMMENT '选项',
              `uid` int(11) DEFAULT NULL,
              `createTime` int(11) DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='错题记录';
            
            CREATE TABLE `question_bank` (
              `id` int(11) NOT NULL AUTO_INCREMENT,
              `question` varchar(200) DEFAULT NULL,
              `option1` varchar(200) DEFAULT NULL,
              `option2` varchar(200) DEFAULT NULL,
              `option3` varchar(200) DEFAULT NULL,
              `option4` varchar(200) DEFAULT NULL,
              `rightOption` varchar(200) DEFAULT NULL,
              `difficultyLevel` int(11) DEFAULT NULL,
              `type` int(11) DEFAULT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='题库';
            
            CREATE TABLE `shield_question_bank` (
              `id` int(11) NOT NULL AUTO_INCREMENT,
              `uid` int(11) NOT NULL,
              `questionNumber` text NOT NULL,
              PRIMARY KEY (`id`)
            ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


         ";
        $this->execute($CreateTableSQL);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m200804_060644_initialize cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m200804_060644_initialize cannot be reverted.\n";

        return false;
    }
    */
}
